﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WRSManagementSystem.Models
{
    public class ProjectRepoFake : Model.Repos.IProjectsRespoitory
    {

        static List<Model.Project> list = new List<Model.Project>() {
                new Model.Project() { Id= Guid.NewGuid(), Name = "Project1" },
                new Model.Project() { Id= Guid.NewGuid(), Name = "Project2" },
                new Model.Project() { Id= Guid.NewGuid(), Name = "Project3" },
                new Model.Project() { Id= Guid.NewGuid(), Name = "Project4" }
        };

        #region IRepository<Project> Members

        public int Count()
        {
            throw new NotImplementedException();
        }

        public int Count(System.Linq.Expressions.Expression<Func<Model.Project, bool>> expression)
        {
            throw new NotImplementedException();
        }

        public void Add(Model.Project entity)
        {
            entity.Id = Guid.NewGuid();
            list.Add(entity);
        }

        public void Remove(Model.Project entity)
        {
            throw new NotImplementedException();
        }

        public void Save(Model.Project entity)
        {
            Model.Project per = list.FirstOrDefault(p => p.Id == entity.Id);
            list.Remove(per);
            list.Add(entity);
        }

        public Model.Project FindOne(Guid id)
        {
            return list.AsQueryable<Model.Project>().FirstOrDefault(t => t.Id == id);
        }

        public Model.Project FindOne(System.Linq.Expressions.Expression<Func<Model.Project, bool>> expression)
        {
            throw new NotImplementedException();
        }

        public bool TryFindOne(System.Linq.Expressions.Expression<Func<Model.Project, bool>> expression, out Model.Project entity)
        {
            throw new NotImplementedException();
        }

        public IQueryable<Model.Project> Find()
        {
            return list.AsQueryable<Model.Project>();
        }

        public IQueryable<Model.Project> Find(Guid id)
        {
            return list.AsQueryable<Model.Project>().Where(t => t.Id == id);
        }

        public IQueryable<Model.Project> Find(System.Linq.Expressions.Expression<Func<Model.Project, bool>> expression)
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}
